function selestateInfo(){
	var oper = document.getElementById("info_state").value;
	var listsize = document.getElementById("listsize").value;
	var pkid_string = "";
	for(var i=0;i<listsize;i++){
		if(document.getElementById('checkone'+i).checked){
			pkid_string += document.getElementById("checkone"+i).value+"|";
		}
	}
	if(pkid_string == ""){
		alert("请至少选择一条操作信息!");
		return false;
	}else if(oper == ""){
		alert("请你选择操作方式");
		return false;
	}else if(oper=="0"){
		document.getElementById('pkid').value = pkid_string;
		document.indexForm.action='/doTradeReg.do';
		if(window.confirm('确认删除吗?')){
			document.indexForm.submit();
		}
	}else {
		document.getElementById("case_state").value=oper;
		document.getElementById("bpm_id").value="9065";
		document.getElementById('pkid').value = pkid_string;
		document.indexForm.action='/doTradeReg.do';
		if(window.confirm('确认修改吗?')){
			document.indexForm.submit();
		}
	}
}

function search(){
	var area_attr_str = "";
		if(document.getElementById("cat_attr1").value!=""){
			area_attr_str += document.getElementById("cat_attr1").value+"|";
			if(document.getElementById("cat_attr2").value!=""){
				area_attr_str += document.getElementById("cat_attr2").value+"|";
			}
	}
	if(document.getElementById("xinfo_state").value!=""){
		document.getElementById("sinfo_state").value=document.getElementById("xinfo_state").value;
	}
   	document.getElementById("cat_attr").value = area_attr_str;	
	document.getElementById("case_state").value=document.getElementById("scase_state").value;
	document.indexForm.submit();
}
function trim(val) {
	return val.replace(/(\s*$)/g, "");
}
function setProvince() {
	Ts_areaInfo.getAreaClassByUpId("000000000000000", function (data) {
		DWRUtil.removeAllOptions("province");
		DWRUtil.addOptions("province", {"":"\u8bf7\u9009\u62e9"});
		DWRUtil.addOptions("province", data);
	});
}
function setCitys(prov) {
	var provence = prov;
	Ts_areaInfo.getAreaClassByUpId(provence, function (data) {
		DWRUtil.removeAllOptions("eparchy_code");
		DWRUtil.addOptions("eparchy_code", {"":"\u8bf7\u9009\u62e9"});
		DWRUtil.addOptions("eparchy_code", data);
		DWRUtil.removeAllOptions("city_code");
		DWRUtil.addOptions("city_code", {"":"\u8bf7\u9009\u62e9"});
	});
}
function setAreas(city_id) {
	Ts_areaInfo.getAreaClassByUpId(city_id, function (data) {
		DWRUtil.removeAllOptions("city_code");
		DWRUtil.addOptions("city_code", {"":"\u8bf7\u9009\u62e9"});
		DWRUtil.addOptions("city_code", data);
	});
}

function showInfo(val,v){

	if(document.getElementById("div_"+val).style.display=="none")
		document.getElementById("div_"+val).style.display="block";
	else
		document.getElementById("div_"+val).style.display="none";
	//setTimeout("showInfo('"+val+"','"+v+"')","2000");
}
function checkInfo() {
	if (document.getElementById("case_title").value == "") {
		alert("标题不能为空");
		document.getElementById("case_title").focus();
		return false;
	}
	var start_attr = "";
	if (document.getElementById("province").value != "") {
		start_attr = document.getElementById("province").value + "|";
	}
	if (document.getElementById("eparchy_code").value != "") {
		start_attr += document.getElementById("eparchy_code").value + "|";
	}
	if (document.getElementById("city_code").value != "") {
		start_attr += document.getElementById("city_code").value + "|";
	}
	if (start_attr != "") {
		document.getElementById("area_attr").value = start_attr;
	}
	if(document.getElementById("area_attr").value==""){
		alert("涉案地点不能为空");
		document.getElementById("area_attr").focus();
		return false;
	}

	if(document.getElementById("delegate_fee").value == ""){
		document.getElementById("delegate_fee").value = "0";}
	if (document.getElementById("case_amount").value == "") {
		document.getElementById("case_amount").value = "0";}
	//var reg =/^0{0,1}(13[0-9]|15[7-9]|153|156|18[7-9])[0-9]{8}$/;
	//var pon =/^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;
	if(document.getElementById("delegate_tel").value==""){
		alert("联系方式不能为空");
		document.getElementById("delegate_tel").focus();
		return false;
	}
	if(document.getElementById("delegate_name").value==""){
		alert("委托人姓名不能为空");
		document.getElementById("delegate_name").focus();
		return false;
	}
	if(document.getElementById("end_time").value==""){
		alert("截至日期不能为空");
		document.getElementById("end_time").focus();
		return false;
	}

	var area_attr = document.getElementById('cat_attr').value;

		if(document.getElementById('cat_attr1').value != ''){
			area_attr = '';
			area_attr += document.getElementById('cat_attr1').value+'|';
			if(document.getElementById('cat_attr2').value!=''){
				area_attr += document.getElementById('cat_attr2').value+'|';
			 }
		}
		if(area_attr == ''){
			alert('请选择案源分类！');
			return false;
		}
		document.getElementById('cat_attr').value = area_attr;

	if (start_attr != "") {
		document.getElementById("area_attr").value = start_attr;
	}
	document.addForm.submit();
}
function delOneNews(val) {
	if (window.confirm("确认要删除这条记录吗？")) {
		window.location.href = "/doTradeReg.do?pkid=" + val + "&bpm_id=6382";
	}
}
function sortNews(val) {
	var elem = val.form.elements;
	var all_news_text = "";
	for (i = 0; i < elem.length; i++) {
		if (elem[i].type == "text" && elem[i].id != "link_name" && elem[i].id != "i_display") {
			all_news_text += elem[i].id + "," + elem[i].value + "|";
		}
	}
    //alert(all_news_text);
	document.indexForm.action = "/doTradeReg.do";
	document.getElementById("sort").value = all_news_text;
	document.getElementById("bpm_id").value = "2518";
	document.indexForm.submit();
}
function shenhe(pkid, bpm_id) {
	window.location.href = "/doTradeReg.do?case_id=" + pkid + "&bpm_id=" + bpm_id;
}
function deleteOneInfo(pkid, bpm_id) {
	if (window.confirm("确定要删除吗？")) {
		window.location.href = "/doTradeReg.do?pkid=" + pkid + "&bpm_id=" + bpm_id;
	}
}

function setcat_attr1(val) {
	Ts_categoryInfo.getCatClassByUpId('000000000000000','2',function(data){
		DWRUtil.removeAllOptions(val+'cat_attr1');
		DWRUtil.addOptions(val+'cat_attr1',{'':'请选择'});
		DWRUtil.addOptions(val+'cat_attr1',data);
	});
}

function setcat_attr2(prov,val){
	var provence=prov;
	 Ts_categoryInfo.getCatClassByUpId(provence,'2',function(data){
		DWRUtil.removeAllOptions(val+'cat_attr2');
		DWRUtil.addOptions(val+'cat_attr2',{'':'请选择'});
		DWRUtil.addOptions(val+'cat_attr2',data);
	});
}

function showDiv(val){
	if(val==1){
		if(document.getElementById("area_div").style.display=="none"){
			document.getElementById("area_div").style.display="block";
		}else{
			document.getElementById("area_div").style.display="none";
		}
	}else{
		if(document.getElementById("cat_div").style.display=="none"){
			document.getElementById("cat_div").style.display="block";
		}else{
			document.getElementById("cat_div").style.display="none";
		}
	}
	
}

function CPos(x, y)
{
    this.x = x;
    this.y = y;
}

function GetObjPos(ATarget)
{
    var target = ATarget;
    var pos = new CPos(target.offsetLeft, target.offsetTop);
   
    var target = target.offsetParent;
    while (target)
    {
        pos.x += target.offsetLeft;
        pos.y += target.offsetTop;
       
        target = target.offsetParent
    }
   
    return pos;
}

function getLawyerInfo(val){
	Ti_LawyerInfo.getUserInfo(val, function (data) {
		document.getElementById("thelayer").innerHTML=data;
	});
}
function showlayer(val,obj) {
	if(document.getElementById("thelayer").style.display=="none"){
		 pos = GetObjPos(obj);
		 l = document.getElementById("thelayer");
		 l.style.left = pos.x + 10;
		 l.style.top = pos.y + 10;
		 l.style.display="block";
		 getLawyerInfo(val);
	}else{
		document.getElementById("thelayer").style.display="none";
	}
		
	
}
